package com.ibm.ems.servlets;

import java.io.IOException;
import java.sql.Connection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibm.ems.dao.TopicsDao;
import com.ibm.ems.dto.TopicBean;
import com.ibm.ems.util.ConnectionUtil;

/**
 * Servlet implementation class TopicModifyServlet
 */
public class TopicModifyServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		TopicBean p=new TopicBean();
		Connection conn = ConnectionUtil.getConnection();
		TopicsDao td1=new TopicsDao(conn);
		
		
		
		RequestDispatcher rd;
		
		if(request.getParameter("topicscode")!=null)
		{
			p.setTopicId(request.getParameter("topicscode"));
	 rd=request.getRequestDispatcher("/topicModify.jsp");
			td1.modify(p);
		request.setAttribute("b",p );
		rd.forward(request,response);	
		}
		else if(request.getParameter("topicID")!=null)
		{
			int count=0;
			p.setTopicId(request.getParameter("topicscode"));
			rd=request.getRequestDispatcher("/StatusModify.jsp");
			td1.modify(p);
			count=td1.checkpoll(count);
			request.setAttribute("b",p );
			request.setAttribute("c",count);
			rd.forward(request,response);
			
		}
		else
		{}
		
			
			
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
